package com.arnold.www.singleton;

/**
 * @ClassName Singleton_lazyLoading
 * @Description: 懒汉式（存在线程安全问题）
 * @Author Arnold
 * @Date 2020/4/11
 * @Version V2.0
 **/
public class Singleton_lazyLoading {
    //私有化构造方法
    private Singleton_lazyLoading(){}

    private static Singleton_lazyLoading instance;

    //对外暴露获取实例方法
    public static Singleton_lazyLoading getInstance() {
        if (instance==null){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return instance = new Singleton_lazyLoading();
        }
        return  instance;
    }
}